package com.carrot.newsgallery.controller;

import com.carrot.newsgallery.common.R;
import com.carrot.newsgallery.service.NewsMainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(description = "新闻主榜")
@RestController
@RequestMapping("/newsmain")
public class NewsMainController {

    @Autowired
    private NewsMainService newsMainService;

    @GetMapping
    @ApiOperation("查询今日主榜单内容")
    public R getToday(){
        return R.success(newsMainService.getToday(),"查询成功");
    }

    @GetMapping("/{date}/{batch}")
    @ApiOperation("查询主榜历史信息")
    public R getHistory(@PathVariable String date, @PathVariable int batch){
        return R.success(newsMainService.getHistory(date,batch),"查询成功");
    }
}
